package com.sc.nft.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.dao.NoticeInfoDao;
import com.sc.nft.entity.NoticeInfo;
import com.sc.nft.entity.vo.NoticeInfoVO;
import com.sc.nft.entity.vo.ZhiTanNoticeVO;
import com.sc.nft.service.NoticeInfoService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 服务接口实现
 *
 * @author rdg
 * @description 由 Mybatisplus Code Generator 创建
 * @since 2022-05-30 10:09:02
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class NoticeInfoServiceImpl implements NoticeInfoService {

    private final NoticeInfoDao noticeInfoDao;

    /**
     * 获取公告栏N条记录
     */
    @Value("${announcement.frequency}")
    private Long announcementFrequency;

    @Override
    public Page<NoticeInfo> listPagedNotice(int pageNo, int pageSize) {

        return noticeInfoDao.listPagedNotice(pageNo, pageSize);
    }

    @Override
    public List<ZhiTanNoticeVO> noticeList(Integer page, Integer pageSize) {
        return noticeInfoDao.noticeList(page, pageSize);
    }

    @Override
    public List<NoticeInfoVO> listNotice() {
        if (ObjectUtil.isNotNull(announcementFrequency)) {
            return noticeInfoDao.listNotice(announcementFrequency);
        }
        return null;
    }
    @Override
    public NoticeInfoVO getOneById(Long id) {
        return  noticeInfoDao.getOneById(id);
    }
}